from sqlalchemy import Column, Integer, String

# from bin.dataBase.main import Base
from apps.main import Base


class User(Base):
    # 定义表名
    __tablename__ = 'user'
    __table_args__ = {'extend_existing': True}  # 避免二次创建表问题，如果已经存在了的话就更新
    # 定义字段
    # primary_key=True 设置为主键
    userid = Column(Integer, primary_key=True)
    username = Column(String(255), nullable=False)
    sex = Column(String(60), nullable=True)
    test = Column(String(60), nullable=True)

    # 构造函数
    def __init__(self, userid, username, sex):
        self.userid = userid
        self.username = username
        self.sex = sex

    # 打印形式
    def __str__(self):
        return "id:%s, name:%s, sex:%s" % (str(self.userid), self.username, self.sex)
